<template>
  <div style="width:400px">
    <n-input v-model:value="cateName"></n-input>
  </div>
</template>
<script setup lang="tsx">
import { GoodsAPI } from '@/app/api';
import { ref } from 'vue';

let props = defineProps<{
  category?: any
}>()

let cateName = ref(props.category?.cateName || '')
let cateId = ref(props.category?.id || '')

defineExpose({
  submit() {
    if (props.category) {
      return GoodsAPI.updateCategory({ id: cateId.value, cateName: cateName.value })
    }
    else {
      return GoodsAPI.addCategory({ cateName: cateName.value })
    }
  }
})

</script>